/*
 * TPS929xxx_APIs.h
 *
 */

#ifndef TPS929120_APIS_H_
#define TPS929120_APIS_H_
#include "Cpu.h"

extern uint16_t read_offset;

// Channel APIs
void enableCh(uint16_t dev_addr_x, uint16_t *ch_list, uint16_t channel_cnt);
void enableAllCh(uint16_t dev_addr_x);
void disableAllCh(uint16_t dev_addr_x);
void setCh(uint16_t dev_addr_x, uint16_t *ch_list, uint16_t channel_cnt);
void unsetCh(uint16_t dev_addr_x, uint16_t *ch_list, uint16_t channel_cnt);

// PWM APIs
void setPWMAllCh(uint16_t dev_addr_x, uint16_t *pwm_val, uint16_t same_val);
void setPWMhighAllCh(uint16_t dev_addr_x, uint16_t *pwm_val, uint16_t same_val);
void setPWMlowAllCh(uint16_t dev_addr_x, uint16_t *pwm_val, uint16_t same_val);
void setPWMoneCh(uint16_t dev_addr_x, uint16_t *pwm_val, uint16_t channel);
void setPWMhighOneCh(uint16_t dev_addr_x, uint16_t *pwm_val, uint16_t channel);
void setPWMlowOneCh(uint16_t dev_addr_x, uint16_t *pwm_val, uint16_t channel);
void enableExpPWM(uint16_t dev_addr_x);
void disableExpPWM(uint16_t dev_addr_x);
void setPWMfreq(uint16_t dev_addr_x, uint16_t pwm_freq);
void enablePWMshare(uint16_t dev_addr_x);
void disablePWMshare(uint16_t dev_addr_x);

// Current setting APIs
void setRefRange(uint16_t dev_addr_x, uint16_t ref_range);
void setIOUTAllCh(uint16_t dev_addr_x, uint16_t *iout_val, uint16_t same_val);
void setIOUToneCh(uint16_t dev_addr_x, uint16_t *iout_val, uint16_t channel);

// Diagnostics APIs
void LED_Update_Chip_Status(uint16_t dev_addr_x);
void enableDiagCh(uint16_t dev_addr_x, uint16_t *ch_list, uint16_t channel_cnt);
void enableDiagAllCh(uint16_t dev_addr_x);
void disableDiagAllCh(uint16_t dev_addr_x);
void setDiagCh(uint16_t dev_addr_x, uint16_t *ch_list, uint16_t channel_cnt);
void unsetDiagCh(uint16_t dev_addr_x, uint16_t *ch_list, uint16_t channel_cnt);
void enableDiagMask(uint16_t dev_addr_x, uint16_t mask);
void enableOutMask(uint16_t dev_addr_x, uint16_t mask);
void enableSLS(uint16_t dev_addr_x);
void disableSLS(uint16_t dev_addr_x);
void setSLSth(uint16_t dev_addr_x, uint16_t threshold_val, uint16_t threshold_set);
void setLowSupplyTh(uint16_t dev_addr_x, uint16_t threshold_val);
uint16_t checkErrFlag(uint16_t dev_addr_x);
uint16_t getErrFlags(uint16_t dev_addr_x);
uint16_t checkPorFlag(uint16_t dev_addr_x);
uint16_t checkSupFlags(uint16_t dev_addr_x);
uint16_t checkEepcrcFlag(uint16_t dev_addr_x);
void getOpenCh(uint16_t dev_addr_x, uint16_t *ch_list);
void getShortCh(uint16_t dev_addr_x, uint16_t *ch_list);
void getSLSCh(uint16_t dev_addr_x, uint16_t *ch_list);

// Miscellaneous APIs
void setLock(uint16_t dev_addr_x, uint16_t lock);
void clearLock(uint16_t dev_addr_x, uint16_t lock);
void clearLockAll(uint16_t dev_addr_x);
void setClr(uint16_t dev_addr_x, uint16_t clr_val);
void defaultReg(uint16_t dev_addr_x);
uint16_t checkFlag(uint16_t dev_addr_x, uint16_t reg_addr, uint16_t flag);
uint16_t getADCvalue(uint16_t dev_addr_x, uint16_t adc_in, uint16_t convert_res);
void writeSingleReg(uint16_t dev_addr_x, uint16_t reg_addr, uint16_t value, uint16_t enable, uint16_t writeWOread);
void forceFailSafe(uint16_t dev_addr_x);
void forceErr(uint16_t dev_addr_x);

// EEPROM APIs
void enableEepMode(uint16_t dev_addr_x);
void disableEepMode(uint16_t dev_addr_x);
void progEepStart(uint16_t dev_addr_x);
uint16_t checkEepProgReady(uint16_t dev_addr_x);
void enableEepSR(uint16_t dev_addr_x);
void disableEepSR(uint16_t dev_addr_x);

#endif /* TPS929120_APIS_H_ */
